package cdu.notFound.service.impl;

import cdu.notFound.Dao.UserDao;
import cdu.notFound.Dao.impl.UserDaoImpl;
import cdu.notFound.model.User;
import cdu.notFound.service.UserService;

public class UserServiceImpl implements UserService {

    UserDao userDaoImpl = new UserDaoImpl();

    public User findByEmail(String email){
        if(email == null || email.equals("")){
            return null;
        }
        return userDaoImpl.findByEmail(email);
    }

    @Override
    public User findById(int id) {
        if(id <= 0)
            return null;
        return userDaoImpl.findById(id);
    }

    public boolean register(User user){
        if(user != null){
            return userDaoImpl.doCreate(user);
        }
        return false;
    }

    public boolean doUpdate(User user){
        if(user == null)
            return false;
        return userDaoImpl.doUpdate(user);
    }
}
